//    Copyright (C) Kherty.  All rights reserved.
using System.Windows;
using System.Windows.Input;
using OpenLS.Drawing.UI;

namespace OpenLS.Chart.UI
{
    partial class ChartAreaResources
    {
        public ChartAreaResources()
        {
            InitializeComponent();
        }
        void OnSetStyle(object sender, ExecutedRoutedEventArgs args)
        {
            ChartArea c = ChartElement.GetChartArea(args.Source as DependencyObject);
            c.Style = (ChartStyle)args.Parameter;
            args.Handled = true;
        }

        void OnFormatChartArea(object sender, ExecutedRoutedEventArgs args)
        {
            var e = (FrameworkElement)sender;
            PropertyHelper.ShowPropertiesFor(ChartElement.GetChartArea(e), e, ChartCommands.FormatChartArea.Text, PropertyTabHint.None);
        }
        void OnFormat3DRotation(object sender, ExecutedRoutedEventArgs args)
        {
            var e = (FrameworkElement)sender;
            PropertyHelper.ShowPropertiesFor(ChartElement.GetChartArea(e), e, ChartCommands.FormatChartArea.Text, PropertyTabHint.View3D);
        }


        private void OnChartAreaLoaded(object sender, RoutedEventArgs args)
        {
            var e = (FrameworkElement)sender;
            ChartArea chartArea = (ChartArea) e.DataContext;
            WeakEventHelper.AddWeakPropertyChanged(chartArea, (o, eventArgs) =>
                                             {
                                                 if (eventArgs.PropertyName == "Theme")
                                                 {
                                                     DrawingElement.SetTheme(e, chartArea.Theme);
                                                     if (chartArea.Theme != null)
                                                     {
                                                         DrawingElement.SetColorScheme(e, chartArea.Theme.ColorScheme);
                                                     }
                                                 }
                                             });

        }
    }
}
